import 'package:tender_flutter/page/person/model/consumption_entity.dart';

consumptionEntityFromJson(ConsumptionEntity data, Map<String, dynamic> json) {
	if (json['pageNum'] != null) {
		data.pageNum = json['pageNum'] is String
				? int.tryParse(json['pageNum'])
				: json['pageNum'].toInt();
	}
	if (json['pageSize'] != null) {
		data.pageSize = json['pageSize'] is String
				? int.tryParse(json['pageSize'])
				: json['pageSize'].toInt();
	}
	if (json['total'] != null) {
		data.total = json['total'] is String
				? int.tryParse(json['total'])
				: json['total'].toInt();
	}
	if (json['pages'] != null) {
		data.pages = json['pages'] is String
				? int.tryParse(json['pages'])
				: json['pages'].toInt();
	}
	if (json['list'] != null) {
		data.xList = new List<ConsumptionList>();
		(json['list'] as List).forEach((v) {
			data.xList.add(new ConsumptionList().fromJson(v));
		});
	}
	if (json['isFirstPage'] != null) {
		data.isFirstPage = json['isFirstPage'];
	}
	if (json['isLastPage'] != null) {
		data.isLastPage = json['isLastPage'];
	}
	return data;
}

Map<String, dynamic> consumptionEntityToJson(ConsumptionEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['pageNum'] = entity.pageNum;
	data['pageSize'] = entity.pageSize;
	data['total'] = entity.total;
	data['pages'] = entity.pages;
	if (entity.xList != null) {
		data['list'] =  entity.xList.map((v) => v.toJson()).toList();
	}
	data['isFirstPage'] = entity.isFirstPage;
	data['isLastPage'] = entity.isLastPage;
	return data;
}

consumptionListFromJson(ConsumptionList data, Map<String, dynamic> json) {
	if (json['times'] != null) {
		data.times = json['times'].toString();
	}
	if (json['orderNo'] != null) {
		data.orderNo = json['orderNo'].toString();
	}
	if (json['pay'] != null) {
		data.pay = json['pay'].toString();
	}
	if (json['expireDate'] != null) {
		data.expireDate = json['expireDate'].toString();
	}
	if (json['id'] != null) {
		data.id = json['id'].toString();
	}
	if (json['mark'] != null) {
		data.mark = json['mark'].toString();
	}
	if (json['createDate'] != null) {
		data.createDate = json['createDate'].toString();
	}
	if (json['isPayed'] != null) {
		data.isPayed = json['isPayed'];
	}
	return data;
}

Map<String, dynamic> consumptionListToJson(ConsumptionList entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['times'] = entity.times;
	data['orderNo'] = entity.orderNo;
	data['pay'] = entity.pay;
	data['expireDate'] = entity.expireDate;
	data['id'] = entity.id;
	data['mark'] = entity.mark;
	data['createDate'] = entity.createDate;
	data['isPayed'] = entity.isPayed;
	return data;
}